let a = ['1', '2'];

let p = new Proxy(a, {
  set: function (obj, prop, value) {
    console.log('set:', obj, prop, value);
    return Reflect.set(obj, prop, value); // 需要返回true表示成功设置
  },
  get: function (target, property, receiver) {
    console.log('get:', target, property, receiver);
    return Reflect.get(target, property, receiver); // 需要返回目标对象的属性值
  }
});

p.push('3');

// get: (2) ['1', '2'] push Proxy {0: '1', 1: '2'}
// proxy数组和push.js:9
// get: (2) ['1', '2'] length Proxy {0: '1', 1: '2'}
// proxy数组和push.js:9
// set: (2) ['1', '2'] 2 3
// proxy数组和push.js:5
// set: (3) ['1', '2', '3'] length 3